package cn.jbit.order.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.jbit.order.dao.OrderMapper;
import cn.jbit.order.service.OrderService;
import cn.jbit.pojo.Order;

/**
 * 订单service的实现层
 * @author _Cpxy
 *
 */
@Service
public class OrderServiceImpl implements OrderService{

	@Autowired
	private OrderMapper od;
	
	@Override
	public List<Order> showOrderById(Integer id) {
		// TODO Auto-generated method stub
		return od.showOrderById(id);
	}

	@Override
	public Page<Order> showAll(Integer pageNum) {		// pageNum   当前页面
		// TODO Auto-generated method stub
		//调用方法
		Page<Order> pages = PageHelper.startPage(pageNum, 4);
		//执行查询
		od.showAll();
		return pages;		
	}

	@Override
	public List<Order> showOrderByState(Integer states,Integer pageNum) {
		Page<Order> pages = PageHelper.startPage(pageNum, 4);
		//执行查询
		od.showOrderByState(states);
		// TODO Auto-generated method stub
		return pages;
	}
	
	@Override
	public List<Order> showAlls(Integer userid) {
		// TODO Auto-generated method stub
//		Page<Order> pages = PageHelper.startPage(pageNum, 4);
//		//执行查询
		
		return od.showAlls(userid);
	}

	@Override
	public Page<Order> showOrderByIS(String Oname,Integer pageNum) {
		// TODO Auto-generated method stub
		Page<Order> pages = PageHelper.startPage(pageNum, 4);
		//执行查询
		String name = "%"+Oname+"%";
		od.showOrderByIS(name);
		// TODO Auto-generated method stub
		return pages;
	}

	@Override
	public void updateOrder(int id) {
		// TODO Auto-generated method stub
		od.updateOrder(id);		
	}

	@Override
	public void deleteOrder(int id) {
		// TODO Auto-generated method stub
		od.deleteOrder(id);
	}

	@Override
	public int sumOrder() {
		// TODO Auto-generated method stub
		return od.sumOrder();		
	}

	@Override
	public int sumOrders() {
		// TODO Auto-generated method stub
		return od.sumOrders();
	}

	@Override
	public int sumOrderse() {
		// TODO Auto-generated method stub
		return od.sumOrderse();
	}

	@Override
	public int sumOredersee(String Oname) {
		// TODO Auto-generated method stub
		String name = "%"+Oname+"%";
		return od.sumOredersee(name);
	}
}
